import Vue from "vue";
import App from "@/App.vue";
import store from "./vue-config/store";
import router from "./vue-config/router";
import "@/vue-config/plugins";
import vuetify from "./vue-config/plugins/vuetify";
import { sync } from "vuex-router-sync";

import "roboto-fontface/css/roboto/roboto-fontface.css";
import "@mdi/font/css/materialdesignicons.css";
import "@/sass/fonts/font.css";
import Hooks from "@/frame-config/Hooks";
import NormalTool from "@/utils/frame/NormalTool";

// 在调试模式使用 mock
console.log(process.env);
if (
  process.env.NODE_ENV !== "production" ||
  process.env.RUN_MODE === "single"
) {
  let mock: Function | undefined = undefined;
  import("../mock").then(module => {
    mock = module.default;
    mock();
    (async function() {
      await NormalTool.sleep(1000);
      console.log("设置mock");
      store.set<boolean>("app/mockInited", true);
    })();
    console.log("设置mock中");
  });
}

Vue.config.productionTip = false;

sync(store, router);

Hooks.init();

new Vue({
  router,
  store,
  vuetify,
  render: h => h(App)
}).$mount("#app");
